package com.mmlc.meimei.lichengkongjian.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.mmlc.meimei.lichengkongjian.R;


/**
 * Created by Administrator on 2016/7/21 0021.
 */
public class CustomDialog  {

    public final Dialog dialog;
    int layoutId;
    public View view;
    Context context;

    public CustomDialog(Context context) {
        this.context = context;
        dialog = new Dialog(context, R.style.BuyDialogStyle);
    }

    public View getContentView() {
        return view;
    }

    public void setView(int layoutId) {
        this.layoutId = layoutId;
        view = View.inflate(context, layoutId, null);
        dialog.setContentView(view);

        Window dialogWindow = dialog.getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams params = dialogWindow.getAttributes();
        params.width = context.getResources().getDisplayMetrics().widthPixels;
        params.x = 0;
        params.y = 0;
        dialogWindow.setAttributes(params);

    }

    public void show() {
        dialog.show();
    }

}